package com.fenghuanghui.higuojian;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.webkit.WebView;
import android.webkit.WebViewClient;

/**
 * 网页加载前的提示�?
 * 
 * @author zhaoys
 * 
 */
public class CustomWebViewClient extends WebViewClient {

    public CustomWebViewClient(Context pcontext) {
	this.context = pcontext;
    }

    private Context context;

    public Dialog dialog;

    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {// 网页页面�?��加载的时�?
	if (null == dialog)
	     dialog = DialogUtil.createLoadingDialog(context, "加载中..");
	dialog.show();
	view.setEnabled(false);// 当加载网页的时�?将网页进行隐�?
	super.onPageStarted(view, url, favicon);
    }

    @Override
    public void onPageFinished(WebView view, String url) {// 网页加载结束的时�?
	// super.onPageFinished(view, url);
	if (null != dialog)
	    dialog.cancel();
	view.setEnabled(true);
    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) { // 网页加载时的连接的网�?
	view.loadUrl(url);
	return false;
    }
}